<?php
include("db/connect.php");
$sqlcount ="select count(*) AS countorder from orders where cus_id='".$_POST["cus_id"]."' and orders_status='000'";
// or orders_status='001' or orders_status='011')
$querycount=mysql_query($sqlcount);
$fetchcount=mysql_fetch_array($querycount);
if($fetchcount["countorder"]==0){
$sqlagree="insert into orders(cus_id,orders_date,orders_status,emp_id) values('".$_POST["cus_id"]."','".date("Y-m-d")."','000',7)";
$queryagree=mysql_query($sqlagree);
$sqlorder="select orders_id from orders order by orders_id desc";
$queryorder=mysql_query($sqlorder);
$resultorder=mysql_fetch_array($queryorder);
$sqlupdatecart="update cart set orderid='".$resultorder["orders_id"]."' where orderid='0'";
$queryupdatecart=mysql_query($sqlupdatecart);
}else{
	echo "1";
	}
?>